package com.bestcem.xm.ticket.grpc.client.enums.survey;

import lombok.Getter;

/**
 * 数据状态
 *
 * @author zq.ding <zq.ding@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/27 16:05
 */
@Getter
public enum RespondentDataStatusEnum {
    // 测试
    RESPONDENT_DATA_STATUS_TEST("测试", 0),
    // 正式
    RESPONDENT_DATA_STATUS_FORMAL("正式", 1);

    private final String name;
    private final Integer index;

    RespondentDataStatusEnum(String name, Integer index) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 枚举index
     * @author zq.ding <zq.ding@idiaoyan.com>
     * @date 2021/8/31 13:35
     */
    public static RespondentDataStatusEnum getByIndex(Integer index) {
        for (RespondentDataStatusEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
